import type { Dayjs } from 'dayjs';

import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace EdubaseAcademicYearApi {
  /** 学年信息 */
  export interface EduAcademicYear {
    id: number; // 主键ID
    academicYear?: string; // 学年编码
    academicName?: string; // 学年名称
    startDate?: Dayjs | string; // 学年开始日期
    endDate?: Dayjs | string; // 学年结束日期
    status?: number; // 状态：0-未开始 1-进行中 2-已归档
    isCurrent: number; // 是否当前学年
    currentSemesterType?: number; // 当前学期类型：1-第一学期 2-第二学期 3-暑期学期 4-寒假学期
    remark: string; // 备注
  }
}

/** 查询学年分页 */
export function getAcademicYearPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<EdubaseAcademicYearApi.EduAcademicYear>>(
    '/edu/base/academic-year/page',
    data,
    { desensitize, encrypt },
  );
}

/** 查询学年详情 */
export function getAcademicYear(id: number) {
  return requestClient.get<EdubaseAcademicYearApi.EduAcademicYear>(
    `/edu/base/academic-year/get?id=${id}`,
  );
}

/** 新增学年 */
export function createAcademicYear(
  data: EdubaseAcademicYearApi.EduAcademicYear,
) {
  return requestClient.post('/edu/base/academic-year/create', data);
}

/** 修改学年 */
export function updateAcademicYear(
  data: EdubaseAcademicYearApi.EduAcademicYear,
) {
  return requestClient.put('/edu/base/academic-year/update', data);
}

/** 删除学年 */
export function deleteAcademicYear(id: number) {
  return requestClient.delete(`/edu/base/academic-year/delete?id=${id}`);
}

/** 批量删除学年 */
export function deleteAcademicYearList(ids: number[]) {
  return requestClient.delete(
    `/edu/base/academic-year/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出学年 */
export function exportAcademicYear(params: any) {
  return requestClient.download('/edu/base/academic-year/export-excel', {
    params,
  });
}
